package com.example.medicine.View;


import com.example.medicine.Bean.yonghu;
import com.example.medicine.Mapper.TeamMapper;
import com.example.medicine.Mapper.yonghuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

import java.util.List;

@Controller
//@SessionAttributes("image")
public class userView {
    @Autowired
    private yonghuMapper yonghuMapper;
    @Autowired
    private TeamMapper teamMapper;
    @RequestMapping("/user/create")
    public String systemroleCreateShow(Model model){
        List<String> teamname = teamMapper.getTeam();
        model.addAttribute("teamname", teamname);
        return "pages/user/create";
    }
    /**
     * user编辑展示页面
     */
    @RequestMapping("/user/edit/{id}")
    public String getsystemroleById(@PathVariable String id, Model model) {
        yonghu yonghu= yonghuMapper.getById(id);
        List<String> teamname = teamMapper.getTeam();
        yonghu.setUserid(id);
        String image="/uploadImages/"+yonghu.getImage();
        model.addAttribute("yonghu", yonghu);
        model.addAttribute("image", image);
        System.out.println(image);
        model.addAttribute("teamname", teamname);
        return "pages/user/edit";
    }
    @RequestMapping("/user/batchAdd")
    public String batchAddShow(){
        return "pages/User/batchAdd";
    }
    @RequestMapping("/updatepassword/{id}")
    public String updatepassword(@PathVariable String id, Model model){
        System.out.println(id);
        model.addAttribute("userid", id);
        return "pages/updatepassword";
    }
}
